package com.onepiece.im.test.ControllerTest

import com.onepiece.api.im.ReturnT
import com.liveinstars.api.im.vo.FansVO
import com.onepiece.im.service.IFansService
import com.onepiece.im.test.UnitSpecSupport
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.http.HttpStatus

class FanControllerTest3 extends UnitSpecSupport{
    @Autowired
    TestRestTemplate restTemplate

    @MockBean
    IFansService fansDao

    def '/fans should return ok'() {
        given:
        1 * fansDao.getMyFansList(1) >> new ReturnT<>(new ArrayList<FansVO>())

        when:
        def entity = restTemplate.getForEntity('/fans', new ReturnT<List<FansVO>>())

        then:
        entity.statusCode == HttpStatus.OK
    }
}
